;--------------------------------------
;
; prog2-1.asm
;
; Demonstration of MASM 6.0 PROTO, PROC
; and INVOKE directives using PASCAL
; calling conventions
;

;--------------------------------------
;
; include all defines, macros, 
; prototypes and set up memory model
;

include tab6.inc


;--------------------------------------
;
; Create stack
;

    .Stack                         ; 1 k by default

;--------------------------------------
;
; Declare data segment
;

        .Data

hello      db    'Hello Chuck!',0
counter    db    0                      ; loop counter

;--------------------------------------
;
; Begin code segment
;

    .Code


;--------------------------------------
;
; Start program here
;

    .Startup

;--------------------------------------
;
; clear the screen via bios with the
; normal attribute
;

    INVOKE  clrScrn, NORMAL_ATTR    

;--------------------------------------
;
; move cursor to row 0 column 0
;
;
    INVOKE    mvCur, 0, 0


;--------------------------------------
;
; Main body of program here
; where DOS interrupt 21h function
; 09h is used to print the now-
; infamous "Hello CHuck!" message
; to the screen
;

; create loop which goes through 20 iterations

  .WHILE 1                        ; repeat in endless loop
    INVOKE bdWrite, ds:counter, ds:counter, ADDR hello
    inc    ds:counter             ; increment counter by 1
   .BREAK .IF (ds:counter==20)    ; break out of loop if counter == 20
  .ENDW                           ; end while

IF mdl EQ 3
    pop    ds                     ; restore ds
ENDIF

;--------------------------------------
;
; move the cursor to the bottom of
; the screen
;

    INVOKE    mvCur, 23, 0        ; move cur row 23, col 0


;--------------------------------------
;
; End program and return to DOS
;

    .Exit

;--------------------------------------
;
; End of ASSEMBLY source file
;

    END

;
;--------------------------------------
